package com.yongninger.util;

import java.util.HashMap;

public class DOCWriter {
/*
	@SuppressWarnings("rawtypes")
	public static void searchAndReplace(String srcPath, String destPath,
			Map<String, String> map) {
		try {
			XWPFDocument document = new XWPFDocument(
					POIXMLDocument.openPackage(srcPath));
			Iterator it = document.getTablesIterator();
			while (it.hasNext()) {
				XWPFTable table = (XWPFTable) it.next();
				int rcount = table.getNumberOfRows();
				for (int i = 0; i < rcount; i++) {
					XWPFTableRow row = table.getRow(i);
					List<XWPFTableCell> cells = row.getTableCells();
					for (XWPFTableCell cell : cells) {
						for (Entry<String, String> e : map.entrySet()) {
							if (cell.getText().equals(e.getKey())) {
								cell.removeParagraph(0);
								cell.setText(e.getValue());
							}
						}
					}
				}
			}
			FileOutputStream outStream = null;
			outStream = new FileOutputStream(destPath);
			document.write(outStream);
			outStream.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}*/

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {
		@SuppressWarnings("rawtypes")
		HashMap map = new HashMap();
		map.put("${name}", "234");
		map.put("${tel}", "8886666");
		//String srcPath = "c://yne.doc";
		//String destPath = "c://2.doc";
		//searchAndReplace(srcPath, destPath, map);

	}
}
